<?php
	include 'simple_html_dom.php';
	
	$NORDPOOL_URL = "http://www.nordpoolspot.com/Market-data1/Elspot/Area-Prices/All1/Hourly/";
	$KRAFTNAT_URL = "http://driftsdata.statnett.no/snpsrestapi/PowerData/PowerOverview/?language=se&country=se&callback=Production.UpdateData";
?>
<head>
    <script src="http://www.html5canvastutorials.com/libraries/kinetic-v3.8.4.js">
    </script>
    <script>
        window.onload = function() {
            var stage = new Kinetic.Stage("container", 578, 200);
            var layer = new Kinetic.Layer();
            var group = new Kinetic.Group();
 
            var circle = new Kinetic.Circle({
                x: stage.width / 2,
                y: stage.height / 2 + 10,
                radius: 70,
                fill: "red",
                stroke: "black",
                strokeWidth: 4
            });
 
            circle.on("click", function(evt) {
                alert("You clicked the circle!");
                evt.cancelBubble = true;
            });
 
            group.on("click", function() {
                alert("You clicked on the group!");
            });
 
            layer.on("click", function() {
                alert("You clicked on the layer!");
            });
 
            group.add(circle)
            layer.add(group);
            stage.add(layer);
        };
    </script>
</head>
<body onmousedown="return false;">

	<?php
		$html = new simple_html_dom();
		
		$html->load_file($NORDPOOL_URL);
		
		$table = $html->find('table.rgMasterTable');
		
		foreach($table[0]->find('tr') as $trText){
			foreach ($trText->find('td text') as $tdText){
				echo $tdText . " ";
			}
			echo '<br>';
		}
		
		echo "<br><br>";
		
		$data_kraftnat = file($KRAFTNAT_URL);
		
		foreach(preg_split('/{\"type\":\"/', $data_kraftnat[0]) as $dataRow){
			foreach (preg_split("/\",\"/", $dataRow) as $dataPair){
				foreach (preg_split("/\":\"/", $dataPair) as $data){
					echo $data . ": ";
				}
				echo ", ";
			}
			echo "<br>";
		}
	?>

<!--     <div id="container"> -->
<!--     </div> -->
</body>